<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 500px;
            height: 300px;
            background-color: blueviolet;
        }
        .btn-box {
            width: 100px;
            height: 100px;
            position: absolute;
            left:100px;
            top:55px;           
        }
    </style>
</head>
<body>
    <div class="box">
        <p>我要离职，请批准？</p>
        <button id="btn1">同意</button>
        <div class="btn-box">
            <button id="btn2">不同意</button>
        </div>
    </div>

    <script src="./js/lib/jquery.js"></script>
    <script>
    
        $(function(){
            function calcRandomByLimit(start,end) {
                return start + Math.round(Math.random() * end) ;
            }
            let maxLeft = $('.box').innerWidth() - $('.btn-box').innerWidth();
            let maxTop = $('.box').innerHeight() - $('.btn-box').innerHeight();
         
            let fn = function () {  
                let randomLeft = calcRandomByLimit(0,maxLeft);
                let randomHeight = calcRandomByLimit(0,maxTop);
                $(this).css({left:randomLeft,top:randomHeight});
            }
            $('.btn-box').mouseenter(fn).click(fn);

            $('#btn1').click(function() {
                alert('感谢批准')
            })

        })



    </script>
</body>
</html>